
$(function() {
	validateRule();

	//打开图标列表
    $("#ico-btn").click(function(){
        layer.open({
            type: 2,
			title:'图标列表',
            content: '../../../public/FontIcoList.html',
            area: ['480px', '90%'],
            success: function(layero, index){
                //var body = layer.getChildFrame('.ico-list', index);
                //console.log(layero, index);
            }
        });
    });

});
$.validator.setDefaults({
	submitHandler : function() {
		update();
	}
});
function update() {
 var obj={};
  obj.name = $('#name').val();
  obj.address = $('#address').val();
  obj.areaId = $('#areaId').val();
  obj.areaName = $('#areaName').val();
  obj.id = $('#id').val();

alert(JSON.stringify(obj));
	$.ajax({
		cache : true,
		type : "POST",
		dataType: 'json',
        contentType: 'application/json',
		headers:PRIVATE_HEADERS,
		url : API_SERVER_URL + "res/positionT/update",
		data : JSON.stringify(obj),// 你的formid
		async : false,
		error : function(request) {
			parent.laryer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("保存成功");
				window.parent.location.reload() ;
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				layer.alert(data.msg)
			}

		}
	});

}
function validate() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
        			name : {
        				required : true
        			},
        			address : {
        				required : true
        			},
        			areaName : {
                        required : true
                    }
        		},
        		messages : {
        			name : {
        				required : icon + "请输入建筑名称"
        			},
        			address : {
        				required : icon + "请输入建筑地址"
        			},
        			areaName : {
                        required : icon + "请选择所属区域",
                    }
        		}
	})
}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
        			name : {
        				required : true
        			},
        			address : {
        				required : true
        			},
        			areaName : {
                        required : true
                    }
        		},
        		messages : {
        			name : {
        				required : icon + "请输入建筑名称"
        			},
        			address : {
        				required : icon + "请输入建筑地址"
        			},
        			areaName : {
                        required : icon + "请选择所属区域",
                    }
        		}
	})
}